package com.fbs.wowo.util.rongcloud;

import com.fbs.wowo.chat.entity.Crew;
import com.fbs.wowo.exception.ErrorCode;
import com.fbs.wowo.exception.InputVerifyFailedException;
import com.fbs.wowo.util.common.Constants;
import io.rong.RongCloud;
import io.rong.messages.BaseMessage;
import io.rong.messages.ContactNtfMessage;
import io.rong.messages.InfoNtfMessage;
import io.rong.messages.TxtMessage;
import io.rong.methods.message._private.Private;
import io.rong.methods.message.chatroom.Chatroom;
import io.rong.methods.message.discussion.Discussion;
import io.rong.methods.message.group.Group;
import io.rong.methods.message.history.History;
import io.rong.methods.message.system.MsgSystem;
import io.rong.methods.user.User;
import io.rong.models.Result;
import io.rong.models.group.GroupMember;
import io.rong.models.group.GroupModel;
import io.rong.models.message.GroupMessage;
import io.rong.models.message.PrivateMessage;
import io.rong.models.message.SystemMessage;
import io.rong.models.response.GroupUser;
import io.rong.models.response.GroupUserQueryResult;
import io.rong.models.response.ResponseResult;
import io.rong.models.response.TokenResult;
import io.rong.models.user.UserModel;

import java.util.List;

public class RCUtils {
    /**********************************
     *
     * 各种常量
     *
     **********************************/
    /**
     * 融云开发者appKey
     */
    public static final String appKey = Constants.getRCAppKey();
    /**
     * 融云开发者appSecret
     */
    public static final String appSecret = Constants.getRCAppSecret();
    /**
     * 融云开发者自定义api地址
     */
    public static final String api = "http://api.cn.ronghub.com";

    // extra 0 好友，  1 加群
    public static String REPLY_FRIEND = "0";
    public static String REPLY_GROUP = "1";

    public static String BC_TRANSFER = "0"; // 转账
    public static String BC_RED_SIN = "1";  // 单人红包
    public static String BC_RED_MUT = "2";  // 多人红包
    public static String BC_RED_SIN_R = "3";// 接收单人红包
    public static String BC_RED_MUT_R = "4";// 接收多人红包

    public static String BC_NO_RECV = "0";  // 未领取
    public static String BC_RECV = "1";     // 已领取

    private static final RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret);
    /**
     * TODO 是否会有并发问题
     */

    /**********************************
     *
     * 用户
     *
     **********************************/

    /**
     * 融云：注册新用户
     * 创建融云token
     * @param userId
     * @param username
     * @param photo
     * @return rctoken
     * @throws Exception
     */
    public static String createRCToken(String userId, String username, String photo) throws InputVerifyFailedException {
        //自定义 api 地址方式
        // RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);
        User User = rongCloud.user;
        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/user.html#register
         *
         * 注册用户，生成用户在融云的唯一身份标识 Token
         */
        UserModel user = new UserModel()
                .setId(userId)
                .setName(username)
                .setPortrait(photo);
        TokenResult result = null;// {"code":20005,"msg":"Portrait 参数为必传项"}
        try {
            result = User.register(user);
        } catch (Exception e) {
            e.printStackTrace();// {"code":20005,"msg":"Name 参数为必传项"}
        }

//        getToken:  {"token":"Yt076rvL99TVkADI3gESlM7pvnIrYGVl2B3xFphwrKb5sW46+rkxA1ZDYX3eGhvt04tqbASrbP6uZY72LdQbUA==","userId":"002101","code":200}
        validateResultCode(result, ErrorCode.ERR_RC_REG);
//        try {
//            Result= refreshResult = User.update(user);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
        return result.getToken();
    }

    /**********************************
     *
     * 好友
     *
     **********************************/

    /**
     * 添加好友流程：
     * 1.a请求加b为好友，系统向b发送好友请求
     * 2.b同意好友，前端将a,b id发送过来，添加好友进数据库
     *
     * 入群验证流程：
     *
     * 1.a申请加入B，若不需要验证，直接入群，数据库存入
     * 2.需要验证，B的群主b收到系统消息，申请入群，同意则入群，前端将a,B id发送过来，数据库存入
     */
    /**
     * 融云：发送加好友请求 发送加群请求
     * @param rcMsg 消息体
     * @throws Exception
     */
    public static void invite(RCMessage rcMsg) throws InputVerifyFailedException {
        MsgSystem system = rongCloud.message.system;
        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/system.html#send
         *
         * 发送系统消息
         *
         */
        //{"content":"hello","user":{"id":"4242","name":"Robin","icon":"http://www.demo.com/p1.png"},"extra":"helloExtra"}
//        TxtMessage txtMessage = new TxtMessage("hello", "\"user\":{\"id\":\"4242\",\"name\":\"Robin\",\"icon\":\"http://www.demo.com/p1.png\"");
        TxtMessage txtMessage = new TxtMessage(rcMsg.getContent(),
                "{\"id\":\"" + rcMsg.getSenderId() + "\",\"name\":\"" + rcMsg.getSenderName() + "\",\"icon\":\"http://www.rongcloud.cn/images/logo.png\",\"isGroup\":\"" + rcMsg.getIsGroup() + "\"}");
        String[] targetIds = {rcMsg.getTargetId()};
        SystemMessage systemMessage = new SystemMessage()
                .setSenderId(rcMsg.getSenderId())                  // 发送人id
                .setTargetId(targetIds)                 // 接收人id
                .setObjectName(txtMessage.getType())    // 消息类型
                .setContent(txtMessage)                 // 消息内容
                .setPushContent("this is a push")       // ios
                .setPushData("{'pushData':'hello'}")    //
                .setIsPersisted(0)                      // 是否存在融云
                .setIsCounted(0)                        // 在各端是否计数
                .setContentAvailable(0);                //

        ResponseResult result = null;
        try {
            result = system.send(systemMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
        validateResultCode(result, ErrorCode.ERR_RC_FRIEND_VERIFY);
    }

    /**
     * TODO 发送系统推送信息
     * 玩游戏的时候实时把消息推送到所有人手机上
     */
    public static void sysMsg(String[] targetIds, String msg) throws InputVerifyFailedException {
        MsgSystem system = rongCloud.message.system;
        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/system.html#send
         *
         * 发送系统消息
         *
         */
        //{"content":"hello","user":{"id":"4242","name":"Robin","icon":"http://www.demo.com/p1.png"},"extra":"helloExtra"}
//        TxtMessage txtMessage = new TxtMessage("hello", "\"user\":{\"id\":\"4242\",\"name\":\"Robin\",\"icon\":\"http://www.demo.com/p1.png\"");
        // TODO 要携带的信息
        TxtMessage txtMessage = new TxtMessage(msg,"666消息");
        SystemMessage systemMessage = new SystemMessage()
                .setSenderId("002101"/* TODO 发送者id 暂时不用改*/)                  // 发送人id
                .setTargetId(targetIds)                 // 接收人id
                .setObjectName(txtMessage.getType())    // 消息类型
                .setContent(txtMessage)                 // 消息内容
                .setPushContent("this is a push")       // ios
                .setPushData("{'pushData':'hello'}")    //
                .setIsPersisted(0)                      // 是否存在融云
                .setIsCounted(0)                        // 在各端是否计数
                .setContentAvailable(0);                //

        ResponseResult result = null;
        try {
            result = system.send(systemMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
        validateResultCode(result, ErrorCode.ERR_PUSH_MESSAGE);
    }

    /**
     * TODO 发送彩蛋推送信息
     * 玩游戏的时候实时把消息推送到所有人手机上
     */
    public static void gameDetail(String[] tar) throws InputVerifyFailedException {
        MsgSystem system = rongCloud.message.system;
        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/system.html#send
         *
         * 发送系统消息
         *
         */
        //{"content":"hello","user":{"id":"4242","name":"Robin","icon":"http://www.demo.com/p1.png"},"extra":"helloExtra"}
//        TxtMessage txtMessage = new TxtMessage("hello", "\"user\":{\"id\":\"4242\",\"name\":\"Robin\",\"icon\":\"http://www.demo.com/p1.png\"");
        // TODO 要携带的信息
        TxtMessage txtMessage = new TxtMessage("彩蛋游戏","游戏的消息");
        String[] targetIds = tar;
        SystemMessage systemMessage = new SystemMessage()
                .setSenderId("002101"/* TODO 发送者id 暂时不用改*/)                  // 发送人id
                .setTargetId(targetIds)                 // 接收人id
                .setObjectName(txtMessage.getType())    // 消息类型
                .setContent(txtMessage)                 // 消息内容
                .setPushContent("this is a push")       // ios
                .setPushData("{'pushData':'hello'}")    //
                .setIsPersisted(0)                      // 是否存在融云
                .setIsCounted(0)                        // 在各端是否计数
                .setContentAvailable(0);                //

        ResponseResult result = null;
        try {
            result = system.send(systemMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
        validateResultCode(result, ErrorCode.ERR_PUSH_MESSAGE);
    }


    /**
     * TODO 会议开始推送信息
     * 把会议开始的时间把消息推送到所有人手机上
     */
    public static void meetingStart(String id, String meetingName,Double hh) throws InputVerifyFailedException {
        MsgSystem system = rongCloud.message.system;
        // TODO 要携带的信息
        TxtMessage txtMessage = new TxtMessage("会议开始","您报名的会议"+meetingName+"还有"+hh+"个小时开始");
        if (hh>0){
            txtMessage.setExtra("您报名的会议"+meetingName+"还有"+hh+"个小时开始");
        }else{
            txtMessage.setExtra("您报名的会议"+meetingName+"已经开始了");
        }
        String[] targetIds = {id};
        SystemMessage systemMessage = new SystemMessage()
                .setSenderId("002101"/* TODO 发送者id 暂时不用改*/)                  // 发送人id
                .setTargetId(targetIds)                 // 接收人id
                .setObjectName(txtMessage.getType())    // 消息类型
                .setContent(txtMessage)                 // 消息内容
                .setPushContent("this is a push")       // ios
                .setPushData("{'pushData':'hello'}")    //
                .setIsPersisted(0)                      // 是否存在融云
                .setIsCounted(0)                        // 在各端是否计数
                .setContentAvailable(0);                //

        ResponseResult result = null;
        try {
            result = system.send(systemMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
        validateResultCode(result, ErrorCode.ERR_PUSH_MESSAGE);
    }

    /**
     * 融云：更新融云好友信息
     * @param userId
     * @param username
     * @param photo
     * @throws Exception
     */
    public static void rcUpdate(String userId, String username, String photo) throws InputVerifyFailedException {
        User User = rongCloud.user;
        /**
         *
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/user.html#refresh
         *
         * 刷新用户信息方法
         */
        UserModel user = new UserModel()
                .setId(userId)
                .setName(username)
                .setPortrait(photo);
        Result result = null;
        try {
            result = User.update(user);
        } catch (Exception e) {
            e.printStackTrace();
        }
        validateResultCode(result, ErrorCode.ERR_RC_UPDATE_USERINFO);
    }

    /**********************************
     *
     * 群组
     *
     **********************************/

    /**
     * 融云：创建群组
     * @param crew
     * @throws Exception
     */
    public static void regCrew(Crew crew) throws InputVerifyFailedException {
        io.rong.methods.group.Group Group = rongCloud.group;

        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#create
         *
         * 创建群组方法
         *
         */
        // 群成员
        //		GroupMember[] members = {new GroupMember().setId("ghJiu7H1"),new GroupMember().setId("ghJiu7H2")};
        // 将群主加入群
        GroupMember[] members = {new GroupMember().setId(crew.getUid())};

        // 创建群组
        GroupModel group = new GroupModel()
                .setId(crew.getCid())
                .setMembers(members)
                .setName(crew.getName());
        Result result = null;
        try {
            result = (Result)Group.create(group);
        } catch (Exception e) {
            e.printStackTrace();
        }
        // 返回码不正确则抛出异常
        validateResultCode(result, ErrorCode.ERR_RC_CREATE_GROUP);
    }

    /**
     * 融云：创建群组并拉好友入群
     * @param crew
     * @param uids
     */
    public static void regCrew(Crew crew, String[] uids) throws InputVerifyFailedException {
        io.rong.methods.group.Group Group = rongCloud.group;

        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#create
         *
         * 创建群组方法
         *
         */
        // 群成员
        GroupMember[] members = new GroupMember[uids.length + 1];

        // 将群主加入群
        members[0] = new GroupMember().setId(crew.getCid());
        // 将群众加入群
        for (int i = 1; i < members.length; i++) {
            members[i] = new GroupMember().setId(uids[i - 1]);
        }
        // 创建群组
        GroupModel group = new GroupModel()
                .setId(crew.getCid())
                .setMembers(members)
                .setName(crew.getName());
        Result result = null;
        try {
            result = (Result)Group.create(group);
        } catch (Exception e) {
            e.printStackTrace();
        }
        // 返回码不正确则抛出异常
//        validateResultCode(result, "创建群组失败");
    }

    public static void inviteCrew(String crewId, String crewName, String[] uids) {
        io.rong.methods.group.Group Group = rongCloud.group;
        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#join
         *
         * 邀请用户加入群组
         *
         */
        GroupMember[] members = new GroupMember[uids.length];
        for (int i = 0; i < members.length; i++) {
            members[i] = new GroupMember().setId(uids[i]);
        }

        GroupModel group = new GroupModel()
                .setId(crewId)
                .setName(crewName)
                .setMembers(members);
        try {
            Result result = (Result)rongCloud.group.invite(group);
            System.out.println(result.code);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 融云：加入群组
     * @param crewId
     * @param uid
     * @throws Exception
     */
    public static void joinCrew(String crewId, String uid, String crewName) throws InputVerifyFailedException {
        io.rong.methods.group.Group Group = rongCloud.group;
        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#join
         *
         * 用户加入指定群组
         *
         */
        GroupMember[] members = {new GroupMember().setId(uid)};
//        group = new GroupModel().setId("groupId");
//        GroupUserQueryResult getMemberesult = Group.get(group);
//        List<GroupUser> members = getMemberesult.getMembers();

        GroupModel group = new GroupModel()
                .setId(crewId)
                .setMembers(members)
                .setName(crewName);
        Result result = null;
        try {
            result = (Result)Group.join(group);
        } catch (Exception e) {
            e.printStackTrace();
        }
        validateResultCode(result, ErrorCode.ERR_RC_JOIN_GROUP);

        // 刷新群组信息
    }

    /**
     * 融云：用户退出群组
     * @param crewId
     * @param uid
     * @throws Exception
     */
    public static void quitCrew(String crewId, String uid) throws InputVerifyFailedException {
        io.rong.methods.group.Group Group = rongCloud.group;
        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#quit
         *
         * 退出群组
         *
         */
        GroupMember[] members = {new GroupMember().setId(uid)};
        GroupModel group = new GroupModel()
                .setId(crewId)
                .setMembers(members);
        Result result = null;
        try {
            result = (Result)Group.quit(group);
        } catch (Exception e) {
            e.printStackTrace();
        }
        validateResultCode(result, ErrorCode.ERR_RC_QUIT_GROUP);
    }

    /**
     * 融云：解散群组
     * @param crewId
     * @param ownerId
     * @throws Exception
     */
    public static void removeCrew(String crewId, String ownerId) throws InputVerifyFailedException {
        io.rong.methods.group.Group Group = rongCloud.group;
        /**
         *
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#dismiss
         *
         * 解散群组
         *
         */
        // 设置群主id
        GroupMember[] members = new GroupMember[]{new GroupMember().setId(ownerId)};

        GroupModel group = new GroupModel()
                .setId("groupId")
                .setMembers(members);
        Result result = null;
        try {
            result = (Result)Group.dismiss(group);
        } catch (Exception e) {
            e.printStackTrace();
        }
        validateResultCode(result, ErrorCode.ERR_RC_REMOVE_GROUP);
    }

    public static void crewUpdate(String crewId, String crewName) throws InputVerifyFailedException {
        io.rong.methods.group.Group Group = rongCloud.group;
        /**
         *
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#refresh
         *  刷新群组信息方法
         */
        GroupModel group = new GroupModel()
                .setId(crewId)
                .setName(crewName);
        Result result = null;
        try {
            result = (Result)Group.update(group);
        } catch (Exception e) {
            e.printStackTrace();
        }
        validateResultCode(result, ErrorCode.ERR_RC_UPDATE_GROUP);
    }

    /**
     * 融云：查询群成员
     * @param crewId
     * @return
     * @throws Exception
     */
    public static List<GroupUser> findCrewMember(String crewId) throws InputVerifyFailedException {
        io.rong.methods.group.Group Group = rongCloud.group;
        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#getMembers
         *
         * 查询群成员方法
         *
         */
        GroupModel group = new GroupModel().setId(crewId);
        GroupUserQueryResult getMemberResult = null;
        try {
            getMemberResult = Group.get(group);
        } catch (Exception e) {
            e.printStackTrace();
        }
        List<GroupUser> members = getMemberResult.getMembers();
        return members;
    }

    /**
     * 融云：获取群组大小
     * @param crewId
     * @return
     * @throws InputVerifyFailedException
     */
    public static int crewSize(String crewId) throws InputVerifyFailedException {
        io.rong.methods.group.Group Group = rongCloud.group;
        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#getMembers
         *
         * 查询群成员方法
         *
         */
        GroupModel group = new GroupModel().setId(crewId);
        GroupUserQueryResult getMemberResult = null;
        try {
            getMemberResult = Group.get(group);
        } catch (Exception e) {
            e.printStackTrace();
        }
        List<GroupUser> members = getMemberResult.getMembers();
        return members.size();
    }

    /******************************************************************
     *
     *
     * 发送消息
     *
     *
     ******************************************************************/

    /**
     * 融云：发送系统消息
     * @param rcmsg
     * @throws Exception
     */
    public void sendSysMsg(RCMessage rcmsg) throws InputVerifyFailedException {

        Private Private = rongCloud.message.msgPrivate;
        MsgSystem system = rongCloud.message.system;
        Group group = rongCloud.message.group;
        Chatroom chatroom = rongCloud.message.chatroom;
        Discussion discussion = rongCloud.message.discussion;
        History history = rongCloud.message.history;

        /**
         * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/system.html#send
         *
         * 发送系统消息
         *
         */
        //{"content":"hello","user":{"id":"4242","name":"Robin","icon":"http://www.demo.com/p1.png"},"extra":"helloExtra"}
        TxtMessage txtMessage = new TxtMessage("hello", "helloExtra");
        String[] targetIds = {"2651280140445094444"};
        SystemMessage systemMessage = new SystemMessage()
                .setSenderId("usetId")
                .setTargetId(targetIds)
                .setObjectName(txtMessage.getType())
                .setContent(txtMessage)
                .setPushContent("this is a push")
                .setPushData("{'pushData':'hello'}")
                .setIsPersisted(0)
                .setIsCounted(0)
                .setContentAvailable(0);

        ResponseResult result = null;
        try {
            result = system.send(systemMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("send system message:  " + result.toString());
    }


    /**********************************
     *
     * 发送好友消息
     *
     **********************************/
    public static String Request = "Request";
    public static String AcceptResponse = "AcceptResponse";
    public static String RejectResponse = "RejectResponse";

    public static void friendMsg(String senderId, String targetId, String type, String tip) throws InputVerifyFailedException {
        ContactNtfMessage msg = new ContactNtfMessage(type, "", senderId, targetId, tip);

//        Private Private = rongCloud.message.msgPrivate;
        MsgSystem system = rongCloud.message.system;

        String[] targetIds = {targetId};
        SystemMessage systemMessage = new SystemMessage()
                .setSenderId("usetId")
                .setTargetId(targetIds)
                .setObjectName(msg.getType())
                .setContent(msg)
                .setPushContent("this is a push")
                .setPushData("{'pushData':'hello'}")
                .setIsPersisted(0)
                .setIsCounted(0)
                .setContentAvailable(0);
//        PrivateMessage privateMessage = new PrivateMessage()
//                .setSenderId(senderId)
//                .setTargetId(targetIds)
//                .setObjectName(msg.getType())
//                .setContent(msg)
//                .setPushContent("")
//                .setPushData("{\"pushData\":\"hello\"}")
//                .setCount("4")
//                .setVerifyBlacklist(0)
//                .setIsPersisted(0)
//                .setIsCounted(1)
//                .setIsIncludeSender(1);
        ResponseResult result = null;
        try {
//            result = Private.send(privateMessage);
            result = system.send(systemMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (result != null)
            System.out.println("send friend message:  " + result.toString());
    }

    /**********************************
     *
     * 发送转账 红包消息
     *
     **********************************/
    /**
     * 融云：发送单人红包 转账消息
     * @throws Exception
     */
    public static void moneyMsg(String senderId, String targetId, BaseMessage msg) throws InputVerifyFailedException {

        Private Private = rongCloud.message.msgPrivate;

        String[] targetIds = {targetId};
        PrivateMessage privateMessage = new PrivateMessage()
                .setSenderId(senderId)
                .setTargetId(targetIds)
                .setObjectName(msg.getType())
                .setContent(msg)
                .setPushContent("")
                .setPushData("{\"pushData\":\"hello\"}")
                .setCount("4")
                .setVerifyBlacklist(0)
                .setIsPersisted(0)
                .setIsCounted(1)
                .setIsIncludeSender(1);
        ResponseResult result = null;
        try {
            result = Private.send(privateMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (result != null)
            System.out.println("send friend message:  " + result.toString());
    }

    /**
     * 融云：发送群红包消息
     */
    public static void moneyMsgM(String senderId, String targetId, RedMessage redMessage) throws InputVerifyFailedException {

        Group group = rongCloud.message.group;

        String[] targetIds = {targetId};
        GroupMessage groupMessage = new GroupMessage()
                .setSenderId(senderId)
                .setTargetId(targetIds)
                .setObjectName(redMessage.getType())
                .setContent(redMessage)
                .setPushContent("this is a push")
                .setPushData("{\"pushData\":\"hello\"}")
                .setIsPersisted(0)
                .setIsCounted(1)
                .setIsIncludeSender(1)
                .setContentAvailable(0);
        ResponseResult result = null;
        try {
            result = group.send(groupMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (result != null)
            System.out.println("send group message:  " + result.toString());
    }

    /**
     * 融云：发送通知消息
     */
    public static void sendNotifyMsg(String senderId, String targetId, String content) throws InputVerifyFailedException {

        Private Private = rongCloud.message.msgPrivate;

        InfoNtfMessage infoNtfMessage = new InfoNtfMessage(content, "");
        String[] targetIds = {targetId};
        PrivateMessage privateMessage = new PrivateMessage()
                .setSenderId(senderId)
                .setTargetId(targetIds)
                .setObjectName(infoNtfMessage.getType())
                .setContent(infoNtfMessage)
                .setPushContent("")
                .setPushData("{\"pushData\":\"hello\"}")
                .setCount("4")
                .setVerifyBlacklist(0)
                .setIsPersisted(0)
                .setIsCounted(0)
                .setIsIncludeSender(0);
        ResponseResult result = null;
        try {
            result = Private.send(privateMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (result != null)
            System.out.println("send notify message:  " + result.toString());
    }

    /**********************************
     *
     * 私有方法
     *
     **********************************/

    private static void validateResultCode(Result result, ErrorCode error) throws InputVerifyFailedException {
        if (result == null || result.getCode() != 200) throw new InputVerifyFailedException(error);
    }
}
